<template>
	<view class="">
		<view class="header">
			<view class="header-title">
				<text>零钱理财</text>
				<text>超500,000+人购买</text>
			</view>
			<view class="header-text">
				<text>收益稳健, 轻松理财; 申赎灵活,使用方便; 严控风险.省心之选; 精品热销,先到先得 </text>
			</view>
			<view class="header-icon">
				<image src="../../static/currentZHY/life-icon1.png" mode=""></image>
				<text>为您甄选 活期精品</text>
			</view>
		</view>
		<view class="main">
			<navigator :url="'../current_detail/current_detail?id='+item.id" class="card" v-for="item in currentData"
				:key="item.id">
				<view class="card-title">
					<text>{{item.name}}</text>
					<text>灵活申赎</text>
				</view>
				<view class="card-content">
					<view>
						<text style="color: #f85656;">{{item.lastYearGrowth}}%</text>
						<text>七日年化收益率</text>
					</view>
					<view>
						<text>{{item.payType}}</text>
						<text>1000元起购</text>
					</view>
					<button>立刻购买</button>
				</view>
				<view class="card-footer">
					<text>本基金为货币市场基金, 属于证券投资基金中的高流动性, 低分险品种</text>
				</view>
			</navigator>

			<text class="footer"> • 过往业绩不预示未来表现, 市场有风险, 投资需谨慎</text>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				queryData: {
					name: '',
					page: 1
				},
				currentData: [],
				totalPage: ''
			}
		},
		methods: {
			async getCurrentData() {
				const res = await this.$http.current.getCurrentData(this.queryData);
				if (res.code === 200) {
					console.log(res);
					this.currentData = [
						...this.currentData,
						...res.data.list
					]
					this.totalPage = res.data.pages;
				}
			}
		},
		mounted() {
			this.getCurrentData();
		},
		onReachBottom() {
			if (this.queryData.page >= this.totalPage) {
				wx.showToast({
					title: '没有下一页数据'
				});
			} else {
				this.queryData.page++;
				this.getCurrentData()
			}
		},
		onPullDownRefresh() {
			this.queryData = {
				name: '',
				page: 1
			}
			this.currentData = [];
			this.getCurrentData();
		}
	}
</script>

<style lang="scss" scoped>
	.header {
		padding: 24rpx;
	}

	.header-title {
		display: flex;
		justify-content: space-between;
		align-items: center;

		text:first-child {
			font-size: 48rpx;
			font-weight: bold;
		}

		text:last-child {
			font-size: 32rpx;
			color: #4f4f4f;
		}
	}

	.header-text {
		margin-top: 32rpx;
		font-size: 32rpx;
		color: #4f4f4f;
	}

	.header-icon {
		display: flex;
		align-items: center;
		margin-top: 24rpx;
		height: 60rpx;
		background-image: linear-gradient(to right, #fee6e6, #fff5f5);
		border-top-left-radius: 24rpx;
		border-bottom-left-radius: 24rpx;

		image {
			width: 56rpx;
			height: 56rpx;
		}

		text {
			color: #f85656;
			font-size: 28rpx;
			margin-left: 24rpx;
		}
	}

	// 活期产品样式
	.main {
		padding-bottom: 40rpx;

		.card {
			box-sizing: border-box;
			margin: 0 auto;
			margin-top: 24rpx;
			padding: 40rpx;
			border-radius: 18rpx;
			width: 700rpx;
			// height: 600rpx;
			box-shadow: 0rpx 0rpx 16rpx #efefef;
		}

		.card-title {
			text:last-child {
				margin-left: 24rpx;
				border-radius: 6rpx;
				padding: 8rpx 16rpx;
				font-size: 24rpx;
				color: #c68e3c;
				background-color: #fcf5ec;
			}
		}

		.card-content {
			display: flex;
			margin-top: 32rpx;
			width: 100%;
			justify-content: space-between;
			align-items: center;

			view {
				color: #333333;

				text {
					display: block;
				}

				text:first-child {
					font-size: 38rpx;
					font-weight: bold;
				}

				text:last-child {
					margin-top: 8rpx;
					color: #9e9e9e;
				}
			}

			button {
				font-size: 32rpx;
				margin: 0;
				height: 64rpx;
				line-height: 64rpx;
				background-color: #3476f1;
				color: #FFFFFF;
			}
		}

		.card-footer {
			text {
				display: block;
				padding-bottom: 12rpx;
				padding-top: 24rpx;
				margin-top: 24rpx;
				color: #9e9e9e;
				border-top: 2rpx solid #fbfbfb;
			}
		}
	}

	.footer {
		color: #9e9e9e;
		display: block;
		font-size: 28rpx;
		padding: 24rpx;
	}
</style>
